/**
 * 
 */
package org.jim.server.util;

import org.apache.commons.collections4.CollectionUtils;
import org.jim.core.ImChannelContext;
import org.jim.core.config.ImConfig;
import org.jim.server.JimServerAPI;
import org.jim.server.config.ImServerConfig;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/**
 * IM聊天命令工具类
 * @date 2018-09-05 23:29:30
 * @author WChao
 *
 */
public abstract class ChatKit {
	
	private static Logger log = LoggerFactory.getLogger(ChatKit.class);
     /**
      * 判断用户是否在线
      * @param userId 用户ID
	  * @param isStore 是否开启持久化(true:开启,false:未开启)
      * @return
      */
     public static boolean isOnline(String userId , boolean isStore){
		 if(isStore){
			ImServerConfig imServerConfig = ImConfig.Global.get();
			return imServerConfig.getMessageHelper().getUserHelper().isOnline(userId);
		 }
    	 List<ImChannelContext> imChannelContexts = JimServerAPI.getByUserId(userId);
    	 if(CollectionUtils.isNotEmpty(imChannelContexts)){
    		 return true;
    	 }
    	 return false;
     }




}
